package com.wxl.common.util

import android.graphics.Color
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import com.wxl.common.R

class LayoutHelper {
    
    companion object {


        /**
         * 添加头部布局，带水滴效果
         */
        fun addTitleTopLayout(layout: ViewGroup): View {
            val titleTopLayout = View.inflate(layout.context, R.layout.view_title_top_layout, null)
            val parent = LinearLayout(layout.context)
            parent.orientation = LinearLayout.VERTICAL
            parent.layoutParams = ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT
            )
            parent.setBackgroundColor(Color.WHITE)
            val statusView = View(layout.context)
            statusView.layoutParams = ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                Screen.getStatusBarHeight(layout.context)
            )
            parent.addView(statusView)
            parent.addView(titleTopLayout,ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                DPUtil.dip2px(40)
            ))
            parent.addView(layout,ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT
            ))
            return parent
        }

    }
}


